#include "CES.h"

using namespace std;

void CES::set_specname(string s)
{
	this->spec = s;
}

void CES::add_opns(Operation o)
{
	this->opns.push_back(o);
}

void CES::add_vars(Variable s)
{
	this->vars.push_back(s);
}

void CES::add_eqns(Equation q)
{
	this->eqns.push_back(q);
}

Variable CES::get_var(string s)
{
	for (vector<Variable>::iterator it = this->vars.begin(); it!=this->vars.end(); ++it) 
		if ((*it).get_name() == s)
			return (*it);
	return 0;
}

bool CES::var_exist(string s)
{
	for (vector<Variable>::iterator it = this->vars.begin(); it!=this->vars.end(); ++it) 
		if ((*it).get_name() == s)
			return true;
	return false;
}

bool CES::var_exist(Variable v)
{
	for (vector<Variable>::iterator it = this->vars.begin(); it!=this->vars.end(); ++it) 
		if ((*it).get_name() == v.get_name())
			return true;
	return false;
}

bool CES::opns_exist(string s)
{
	for (vector<Operation>::iterator it = this->opns.begin(); it!=this->opns.end(); ++it) 
		if ((*it).get_name() == s)
			return true;
	return false;
}

Operation CES::get_opns(string s)
{
	for (vector<Operation>::iterator it = this->opns.begin(); it!=this->opns.end(); ++it) 
		if ((*it).get_name() == s)
			return *it;
	return Operation();
}

Equation CES::get_eqns(string s)
{
	for (vector<Equation>::iterator it = this->eqns.begin(); it!=this->eqns.end(); ++it) 
		if ((*it).get_name() == s)
			return *it;
	return Equation();
}

void CES::execute(string opns_name, vector<Variable> vars)
{
	Equation e = this->get_eqns(opns_name);
	e.set_vars(vars);

}